<?php

namespace app\api\controller;

use app\common\controller\Api;
use app\common\model\Report as ModelReport;
use app\common\model\User;

/**
 * 意见反馈
 */
class Report extends Api
{
    protected $noNeedLogin = [''];
    protected $noNeedRight = ['*'];

    /**
     * 提交
     * @Author xy
     * @ApiMethod (POST)
     * @ApiParams (name="msg", type="str", required=true, sample="3", description="意见")
     * 
     * @ApiReturnParams (name="code", type="integer", required=true, description="")
     * @ApiReturn ({'code':0,'msg':'返回成功'})
     */
    function add(){
        $user = $this->auth->getUser();
        $rej = $this->validate(
            $this->request->post(),
            [
                'msg'  => 'require',
            ]
        );
        if (true !== $rej) {
            $this->responseMsg(1005, [], $rej);
        }
        $has = ModelReport::create(['user_id'=>$user->id,'msg'=>$this->request->post('msg')]);
       
        $this->responseMsg(0);
    }
}